package DigitalNetwork;

import java.awt.Color;
import java.awt.Graphics;

public class ButtonView extends UnitView {

    /** [Konstruktor]
     * Hozzaadja a Unitot a View-hoz.
     */
    //==========================================================================
    public ButtonView(Unit u) {
        super(u);
    }
    //==========================================================================

    /**
     *
     * @param g
     * @return
     */
    @Override
    public void draw(Graphics g) {
        // A tartalmazott Unit kasztolasa Button-ra
        Button b = (Button)this.unit;
        
        // Keret es UnitID szine
        g.setColor(Color.BLACK);

        // Keret kirajzolasa
        g.drawRoundRect(0, 0, NetworkView.UNIT_SIZE, NetworkView.UNIT_SIZE, 20, 20);
        g.drawString(b.getID(), 2, NetworkView.UNIT_SIZE/2 + 5 );

        // Button ertekenek szine (1 - zold | 0 - piros
        if(b.getIsHigh()){
            g.setColor(Color.GREEN);
        } else {
            g.setColor(Color.RED);
        }

        // Button ertekenek kirajzolasa
        g.drawString(b.getIsHigh() ? "[1]" : "[0]", NetworkView.UNIT_SIZE - 15, NetworkView.UNIT_SIZE/2 + 5 );
    }
}